//
//  EZTallyObject.cpp
//  EZTallyObject
//
//  Created by ellzu on 13-8-3.
//  Copyright (c) 2013年 ellzu. All rights reserved.
//

#include "EZTallyObject.h"
#include "EZAutoreleasePoolManager.h"

using namespace EZTally;

EZTallyObject::EZTallyObject()
{
    retainCount = 1;
}

EZTallyObject::~EZTallyObject()
{
    
}

EZTallyObject* EZTallyObject::Retain()
{
    retainCount++;
    return this;
}

void EZTallyObject::Release()
{
    retainCount--;
    if (retainCount==0) {
        delete this;
    }
}

void EZTallyObject::AuroRelease()
{
    EZAutoreleasePoolManager *manager = EZAutoreleasePoolManager::DefaultManager();
    EZAutoreleasePool *pool = manager->CurrentPool();
    if (pool==0) {
        std::cout << "AuroRelease Error:: currentAutoreleasePool is 0"<<std::endl;;
        return ;
    }
    pool->AddObject(this);
}

unsigned int EZTallyObject::RetainCount()
{
    return retainCount;
}
